package com.surge;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SurgeMain {

	private static ApplicationContext ctx;

	public static void main(String[] args) {
		
		
		//1. 创建 Spring 的 IOC 容器
		ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

		/*
		 * 从 IOC 容器中获取 bean 的实例
		 * 
		 * 1、使用构造方法注入属性
		 */
		Car car = (Car) ctx.getBean("car");

		System.out.println(car);
		
		/*
		 * 2、重载构造方法
		 */
		Car car2 = (Car) ctx.getBean("car2");
		
		System.out.println(car2);
		
		/*
		 * 3、引用其他bean
		 */
		Person person =  (Person) ctx.getBean("person");
		
		System.out.println(person);
		
		
		
	}

}
